const app = getApp()

Page({
  data: {
    avatar: '',
    nickName: ''
  },
  // onLoad () {
  //   this.getUserInfo()
  // },
  onShow () {
    this.getUserInfo()
  },
  async getUserInfo () {
    const {
      code,
      data: { avatar, nickName }
    } = await wx.http.get('/userInfo')
    console.log(avatar, nickName)

    if (code !== 10000) return wx.utils.toast('获取信息失败,请重新')
    this.setData({ avatar, nickName })

    app.setUserinfo('avatar', avatar)
    app.setUserinfo('nickName', nickName)
  }
})
